/**
 * 
 */
package com.guoxin.chapter2.synblockmoreobjectonelock;

/**
 * @author guoxin
 * @date 2019年8月19日
 */
public class Service {
	public static void printA() {
		synchronized (Service.class) {
			try {
				System.out.println(
						"线程名称为：" + Thread.currentThread().getName() + " 在 " + System.currentTimeMillis() + " 进入了printA");
				Thread.sleep(3000);
				System.out.println(
						"线程名称为：" + Thread.currentThread().getName() + " 在 " + System.currentTimeMillis() + " 离开了printA");
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	
	public  static void printB(){
		synchronized (Service.class) {
			System.out.println(
					"线程名称为：" + Thread.currentThread().getName() + " 在 " + System.currentTimeMillis() + " 进入了printB");
			System.out.println(
					"线程名称为：" + Thread.currentThread().getName() + " 在 " + System.currentTimeMillis() + " 离开了printB");
		}
	}
}
